<template>
  <div class='header'>
    <div class='header-left'>
      <!-- 此处为icon图标的引用方式，注意iconfont.css中的路径要改变 -->
      <div class="iconfont back-icon">&#xe624;</div>
    </div>
    <div class='header-input'>
      <span class="iconfont">&#xe632;</span>
      Input City/Attractions/Play theme 
    </div>
    <router-link to="/city">
      <div class='header-right'>
        <!-- {{this.$store.state.city}} -->
        {{this.city}}
        <span class="iconfont arrow-icon">&#xe62d;</span>     
      </div>
    </router-link>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: 'HomeHeader',
  // 7-9 Vue父组件传来的值，子组件要接收，且控制接收格式
  // props: {
  //   city: String
  // }
  computed: {
    ...mapState(['city'])
  }
}
</script>
<style lang='stylus' scoped>
  // 此处为7-2的内容
  // 1.用一个全局变量来保存常用颜色，未来可维护性更强
  // 2.样式里面引用样式需要加@符号
  // 3.可以在build/webpack-base.conf.js下修改路径别名，例如@的使用
  // 4.简单介绍如何在阿里图库下载使用iconfont
  @import '~styles/varibles.styl'
  @import '~styles/mixins.styl'
  .header
    background: $bgColor
    display: flex
    line-height: $headerHeight
    .header-left
      color: #fff
      float: left
      width: .64rem
      .back-icon
        margin-left: .2rem
        font-size: .4rem
    .header-input
      flex: 1
      height: .64rem
      line-height: .64rem
      padding-left: .1rem
      margin-top: .12rem
      margin-left: .2rem
      margin-right: .1rem
      // margin-bottom: .1rem
      border-radius: .1rem
      background: #fff
      color: #ccc
    .header-right
      float: right
      text-align: center
      mid-width: 1.04rem
      font-size: .34rem
      color: #fff
      // padding: 0 .1rem
      ellipsis()    
      .arrow-icon
        // display: absolute
        // right: .1rem
        margin-left: -.04rem
        // font-size: .25rem
</style>
